package com.hgxd.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hgxd.annotation.OperationLogAnnotation;
import com.hgxd.result.Result;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;
import java.util.List;


import com.hgxd.service.IRobotDetectionTypeService;
import com.hgxd.entity.RobotDetectionType;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 检测类型表 前端控制器
 * </p>
 *
 * @author fsd
 * @since 2023-12-01
 */
@Api(tags = "机器人检测类型表")
@RestController
@RequestMapping("/api/robot-detection-type")
public class RobotDetectionTypeController {
    @Resource(name = "RobotDetectionTypeServiceImpl")
    private IRobotDetectionTypeService robotDetectionTypeService;


    /**
     * 查询全部
     */
    @GetMapping("/getAll")
    @ApiOperation(value = "查询全部", notes = "无需传参")
    @OperationLogAnnotation(operModule = "机器人检测类型表-查询全部",operType = "查询",operContent = "查询全部")
    public Result<List<RobotDetectionType>> findAll() {
        return Result.ok(robotDetectionTypeService.list());
    }

    /**
     * 根据id查询一个
     */
    @GetMapping("getById/{id}")
    @ApiOperation(value = "根据id查询一个", notes = "传入id")
    @ApiImplicitParam(name = "id", value = "id")
    @OperationLogAnnotation(operModule = "机器人检测类型表-根据id查询一个",operType = "查询",operContent = "根据id查询一个")
    public Result<RobotDetectionType> findOne(@PathVariable Integer id) {
        return Result.ok(robotDetectionTypeService.getById(id));
    }

    /**
     * 分页模糊查询
     */
    @PostMapping("/get/page")
    @ApiOperation(value = "分页模糊查询", notes = "传入对应所需参数")
    @OperationLogAnnotation(operModule = "机器人检测类型表-分页模糊查询",operType = "查询",operContent = "分页模糊查询")
    public Result<Page<RobotDetectionType>> findPage(@RequestParam Integer pageNum,
                                                     @RequestParam Integer pageSize) {
        QueryWrapper<RobotDetectionType> queryWrapper = new QueryWrapper<>();
        // 倒序查询
        queryWrapper.orderByDesc("id");
        return Result.ok(robotDetectionTypeService.page(new Page<>(pageNum, pageSize), queryWrapper));
    }
}

